package com.feinno.urcs.group.api;

import com.feinno.urcs.group.entity.CreateGroupArgs;
import com.feinno.urcs.group.entity.GroupCommonArgs;
import com.feinno.urcs.group.entity.GroupIndex;
import com.feinno.urcs.group.entity.GroupInfo;
import com.feinno.urcs.types.MobileNo;
import org.helium.framework.annotations.ServiceInterface;

import java.util.List;

/**
 * Created by Lei Gao on 4/22/15.
 */
@ServiceInterface(id = "group:GroupService")
public interface GroupService {
	/**
	 * Helper Function
	 *
	 * @param groupId
	 * @return
	 * @throws Exception
	 */
	GroupIndex getGroupIndex(int groupId) throws Exception;

	GroupInfo checkAndCreate(CreateGroupArgs req) throws Exception;

	/**
	 * @param index
	 * @return
	 */
	GroupInfo getGroupInfo(GroupIndex index) throws Exception;

	/**
	 * 接受邀请加入群
	 *  @param index
	 * @param memberMobile
	 * @param isAccept     true: 接受加入群 false: 拒绝加入群
	 * @param isPreDefined
	 */
	void processGroupInvite(GroupIndex index, MobileNo memberMobile, boolean isAccept, boolean isPreDefined) throws Exception;

	/**
	 * 邀请成员加入群
	 *
	 * @param index
	 * @param referBy
	 * @param invitees
	 * @throws Exception
	 */
	void inviteGroupMembers(GroupIndex index, MobileNo referBy, MobileNo... invitees) throws Exception;

	/**
	 * 移除群成员
	 *
	 * @param index
	 * @param referBy
	 * @param members
	 * @throws Exception
	 */
	void removeGroupMembers(GroupIndex index, MobileNo referBy, MobileNo... members) throws Exception;

	/**
	 * 解散群
	 *
	 * @param index
	 * @param referBy
	 * @throws Exception
	 */
	void dismissGroup(GroupIndex index, MobileNo referBy) throws Exception;

	/**
	 * 更换群管理员
	 *
	 * @param index
	 * @param referBy
	 * @param referTo
	 * @throws Exception
	 */
	void changeAdmin(GroupIndex index, MobileNo referBy, MobileNo referTo) throws Exception;

	/**
	 * @param index
	 * @param referBy
	 * @throws Exception
	 */
	void quitGroup(GroupIndex index, MobileNo referBy) throws Exception;

	void check(MobileNo fromMobileNo, String groupUri) throws Exception;


	List<Integer> getGroupList(MobileNo mobileNo) throws Exception;

	/**
	 * 这个只用到GroupUri,FromUri,ConversationID,Subject
	 *
	 * @param req
	 * @param subject
	 * @return
	 */
	void changeSubject(GroupCommonArgs req, String subject) throws Exception;

	void updateGroupMemberNickname(GroupIndex index, MobileNo mobileNo, String nickame) throws Exception;

	/**
	 * 群静默, 用于给群内所有人下发 byte
	 * @param groupId
	 * @throws Exception
	 */
	void silenced(int groupId) throws Exception;

	void byeGroup(int groupId, MobileNo fromMobileNo, boolean isOnlyClean);
}
